﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace TracNghiemChonTruong.Class
{
    public class SessionUtils
    {
        #region Common Methods
        public static T Get<T>(string key)
        {
            if (Exist(key))
                return (T)HttpContext.Current.Session[key];
            return default(T);
        }

        public static void Set<T>(string key, T val)
        {
            HttpContext.Current.Session[key] = val;
        }

        public static void Clear(string key)
        {

            HttpContext.Current.Session.Remove(key);
        }

        public static void Clear()
        {
            HttpContext.Current.Session.Clear();
        }

        public static bool Exist(string key)
        {
            return HttpContext.Current.Session[key] != null;
        }
        #endregion

        public static string FullName
        {
            get { return Get<string>("FullName"); }
            set { Set("FullName", value);}
        }


        public static string Mark1
        {
            get { return Get<string>("Mark1"); }
            set { Set("Mark1", value); }
        }
        public static string Mark2
        {
            get { return Get<string>("Mark2"); }
            set { Set("Mark2", value); }
        }
        public static string Mark3
        {
            get { return Get<string>("Mark3"); }
            set { Set("Mark3", value); }
        }
        public static string Mark4
        {
            get { return Get<string>("Mark4"); }
            set { Set("Mark4", value); }
        }
        public static string Mark5
        {
            get { return Get<string>("Mark5"); }
            set { Set("Mark5", value); }
        }
        public static string Mark6
        {
            get { return Get<string>("Mark6"); }
            set { Set("Mark6", value); }
        }
        public static string Best
        {
            get { return Get<string>("Best"); }
            set { Set("Best", value); }
        }
        public static string Second
        {
            get { return Get<string>("Second"); }
            set { Set("Second", value); }
        }

        public static void ClearMark()
        {
            Clear("Mark1");
            Clear("Mark2");
            Clear("Mark3");
            Clear("Mark4");
            Clear("Mark5");
            Clear("Mark6");
            Clear("Best");
            Clear("Second");
        }
    }
}